package zhieasy.cn.xpu_helper.controller.book_market;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import zhieasy.cn.common.vo.ResultVO;
import zhieasy.cn.model.book_market.UserBook;
import zhieasy.cn.service.book_market.SortService;

import java.util.List;

/**
 * @author wangzeya
 * @create 2020-08-13 15:16:00
 */
@Api(tags = "图书接口",value = "排序接口")
//@Api(tags = "排序接口")
@RequestMapping("/book-market")
@RestController
//@ApiImplicitParam(name="bookDTO",value ="国际标准书号",required =true,paramType="form",dataType="String")

public class SortController {
    @Autowired
    private SortService sortService;

    /**
     * 按价格排序
     */
    @ApiOperation(value = "按价格排序", notes = "按价格排序")
    @GetMapping(value = "/sort/price/bookId/{bookId}/bookOrder/{bookOrder}", produces = "application/json;charset=UTF-8")
    public ResultVO<List<UserBook>> priceSort(@ApiParam(value = "书籍Id")@PathVariable("bookId") String bookId ,
                                              @ApiParam(value = "排列顺序,传递参数up,down，二者之一")
                                              @PathVariable("bookOrder") String bookOrder,
                                              @ApiParam("页数,第几页") @RequestParam int pageIndex,
                                              @ApiParam("页数,第几页") @RequestParam int pageSize) {
        return sortService.priceSort(bookId,bookOrder,pageIndex,pageSize);
    }
    /**
     * 按热度排序
     */
    @ApiOperation(value = "按热度排序", notes = "按热度排序")
    @GetMapping(value = "/sort/click/bookId/{bookId}/bookOrder/{bookOrder}", produces = "application/json;charset=UTF-8")
    public ResultVO<List<UserBook>> clicksSort(@ApiParam(value = "书籍Id")@PathVariable("bookId") String bookId ,
                                               @ApiParam(value = "排列顺序,传递参数up,down，二者之一")
                                               @PathVariable("bookOrder") String bookOrder,
                                               @ApiParam("页数,第几页") @RequestParam int pageIndex,
                                               @ApiParam("页数,第几页") @RequestParam int pageSize) {
        return sortService.clicksSort(bookId,bookOrder,pageIndex,pageSize);
    }
    /**
     * 按新旧程度排序
     */
    @ApiOperation(value = "按新旧程度排序", notes = "按新旧程度排序")
    @GetMapping(value = "/sort/degree/bookId/{bookId}/bookOrder/{bookOrder}", produces = "application/json;charset=UTF-8")
    public ResultVO<List<UserBook>> degreeSort(@ApiParam(value = "书籍Id")@PathVariable("bookId") String bookId ,
                                               @ApiParam(value = "排列顺序,传递参数up,down，二者之一")
                                               @PathVariable("bookOrder") String bookOrder,
                                               @ApiParam("页数,第几页") @RequestParam int pageIndex,
                                               @ApiParam("页数,第几页") @RequestParam int pageSize) {
        return sortService.degreeSort(bookId,bookOrder,pageIndex,pageSize);
    }
}
